Skip to content

Conversation

evenkkl
Copy link
Member

@evenkkl evenkkl commented Nov 9, 2026 •

Closes #82

Summary

  • Opening or reloading an album page such as /project2/album/42 on the VM gave an Apache 404. Apache has no file at that path and no fallback to index.html. The links are full page loads from BASE_URL, and the Vite dev server always falls back, so this never showed up locally.

  • docs/VM-setup.md now has the fix for the Apache site config, plus the commands to check and reload it (apachectl configtest, systemctl reload apache2, curl):

    <Directory /var/www/html/project2>
        FallbackResource /project2/index.html
    </Directory>

    I chose this over an .htaccess file because Apache on Debian ignores .htaccess by default (AllowOverride None). Built assets are still served as before, and /graphql is outside /project2/, so the proxy is unaffected.

  • ci.yml: the deploy job now requests /project2/album/1 after publishing the client and again in the smoke checks. It fails if Apache doesn't return 200, so a lost fallback breaks the deploy instead of the site.

  • One-line note in the README's Infrastructure section and a row in docs/AI-USAGE.md.

Before merging

Someone with sudo on the VM has to add the FallbackResource block to the Apache site config and reload Apache before this is merged. Otherwise the new deploy check fails on the next push to main.

Verification

  • prettier --check passes on the four changed files.
  • ci.yml still parses as YAML.
  • Not tested against a live Apache yet. The deploy check tests it on the VM.

Apache had no fallback for client-side routes, so opening or reloading
/project2/album/:id gave a 404. Document the FallbackResource for
/var/www/html/project2 in VM-setup.md and make the deploy job check that
/project2/album/1 returns 200.
@evenkkl evenkkl requested a review from a team as a code owner November 9, 2026 14:38
@evenkkl evenkkl self-assigned this Nov 9, 2026
@erikhfj
Copy link
Member

erikhfj commented Nov 9, 2026

Looked at this properly. The diagnosis and the shape of the fix are right, and the deploy check is the correct guard — it turns "someone forgot the VM step" into a red build instead of a broken deep link.

Three things, none blocking:

1. The <Directory> scoping is the part that matters, and it is correct

FallbackResource inside <Directory /var/www/html/project2> only affects paths that map into that directory, so /graphql (ProxyPass) and client/dist assets are untouched. Worth stating that explicitly in the prose, though: the text says "add this next to the ProxyPass lines", which reads like pasting it into the <VirtualHost> body. FallbackResource is valid in virtual-host context, so that would parse and silently apply to every missing path in the vhost, not only the app. Something like "add this <Directory> block to the same site config file" removes the ambiguity.

2. Applying it is easier as a separate conf file

Editing a site config by hand is the part that makes this feel risky to do over a flaky VPN. A dedicated conf plus a2enconf is idempotent, survives someone rewriting the vhost, and rolls back with one command:

sudo tee /etc/apache2/conf-available/project2-spa.conf >/dev/null <<'EOF'
# SPA fallback: client-side routes such as /project2/album/42 have no file behind them.
<Directory /var/www/html/project2>
    FallbackResource /project2/index.html
</Directory>
EOF
sudo a2enconf project2-spa
sudo /usr/sbin/apachectl configtest
sudo systemctl reload apache2

# expect 200 / 200 / 200
curl -s -o /dev/null -w 'deep link %{http_code}\n' http://localhost/project2/album/1
curl -s -o /dev/null -w 'index     %{http_code}\n' http://localhost/project2/
curl -s -o /dev/null -w 'graphql   %{http_code}\n' -X POST http://localhost/graphql \
  -H 'content-type: application/json' -d '{"query":"{ __typename }"}'

Rollback, if configtest complains: sudo a2disconf project2-spa && sudo systemctl reload apache2. Might be worth putting this block in VM-setup.md instead of the edit-the-site-config instructions; it is the same change, just less to get wrong.

3. One trade-off worth a sentence

With FallbackResource, a genuinely missing file under /project2/assets/ also returns index.html with 200 instead of 404. That is normal for SPAs and not a reason to change the approach, but if an asset ever fails to upload, the browser will report a MIME-type error rather than a 404, which is confusing for ten minutes. A note in the doc saves someone that.

CI is green on the branch (deploy skipped, as expected on a PR). The "before merging" section is accurate: the deploy check means main goes red if this merges before the VM change, and the deploy would stop before restarting the API. So the order is: apply the conf, verify 200, then merge.

The VM step was done as a dedicated conf enabled with a2enconf rather than by
editing the site config, so the runbook now describes the machine that exists.

Keeping it in conf-available means it survives edits to the vhost, does not
need a hand-edit over SSH, and rolls back with one command. The verification
also checks a built asset's content type, not only the status code: a 200 with
text/html would mean the fallback is catching files too, which the status code
alone cannot show.

Notes the trade-off that a genuinely missing asset now returns index.html with
200 instead of 404.
@erikhfj
Copy link
Member

erikhfj commented Nov 9, 2026

Pushed 5e8d2a4 to this branch: docs/VM-setup.md now documents the setup that is actually running on the VM.

What changed

The instructions no longer say to edit the site config by hand. They create a dedicated conf and enable it, which is what was applied on the VM:

sudo tee /etc/apache2/conf-available/project2-spa.conf ...
sudo a2enconf project2-spa
sudo /usr/sbin/apachectl configtest
sudo systemctl reload apache2

Two additions beyond the wording:

  • The verification now checks a built asset's content type, not only the status. A 200 text/html for /project2/assets/*.js would mean the fallback is swallowing files, which a status-code-only check cannot detect. That is the failure mode worth catching.
  • It records the trade-off that a genuinely missing asset now returns index.html with 200 instead of 404, so nobody spends an hour on a MIME error later.
  • A rollback (a2disconf + reload) is included, since the doc is likely to be followed during a rebuild.

README.md and the workflow are untouched; the deploy check and the FallbackResource itself were already correct.

The VM step is done and verified

I applied it while connected to the VM, so the "Before merging" section is satisfied:

deep link /project2/album/1   200, renders the album page
asset                         200 text/javascript
index                         200
graphql                       200

And in a real browser: opening /project2/album/1 directly loads Kind of Blue, reloading it keeps the page, and clicking from search into GRACE 2 navigates to /project2/album/37. Before the change the first two were Apache 404s.

One thing to update when convenient: the PR description still says the step is pending and that it edits the site config. Not worth another commit, but the text no longer matches the doc.

The log stopped at the 2026-11-04 M4 rows, so the review rounds that followed
were missing from it. Adds one row per piece of work, oldest first:

- #77, the millisecond cursor that skipped rows
- #72, the guard that counted `pending` while Vitest reports `skipped`
- #73, the benchmark that measured the wrong predicate, and what measuring both
  showed about the index
- #78 and #79, the removal interaction test and the truncated sentence
- #73/#78, the approvals Gitea invalidated over a moved merge base
- #85, the Apache fallback review and the VM verification

Rows are factual about what the tool proposed and what was checked afterwards,
in the same shape as the existing entries.
@erikhfj erikhfj merged commit 22b00fc into main Nov 9, 2026
3 checks passed
@erikhfj erikhfj deleted the fix/82-apache-spa-fallback branch November 9, 2026 20:26
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apache SPA fallback for album detail pages on the VM
2 participants